﻿using Colorful.Furniture.Extensions;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Colorful.Furniture.ErpCustomerManagement;


/// <summary>
/// 列表输出体
/// </summary>
public class CustomerPagedOutputDto : CustomerBaseOutputDto
{
    /// <summary>
    ///  创建时间
    /// </summary>
    public DateTime? AddTime { get; set; }

    /// <summary>
    ///  创建时间
    /// </summary>
    public string AddTimeFormat => AddTime.ToNullableDateString();

    /// <summary>
    ///  最近登陆时间
    /// </summary>
    public DateTime? LoginTime { get; set; }

    /// <summary>
    ///  最近登陆时间
    /// </summary>
    public string LoginTimeFormat => LoginTime.ToNullableDateString();
}




/// <summary>
/// 详细信息输出体
/// </summary>
public class CustomerDetailOutputDto : CustomerBaseOutputDto
{

    public bool IsDeleted { get; set; }
    public DateTime? DeletedTime { get; set; }
    public Guid? ModifyUserId { get; set; }
    public DateTime? ModifyTime { get; set; }
}

/// <summary>
/// 基础输出体
/// </summary>
public class CustomerBaseOutputDto
{
    /// <summary>
    /// 供应商编码
    /// </summary>
    public Guid Id { get; set; }

    /// <summary>
    /// 供应商名称
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 供应商座机
    /// </summary>
    public string Phone { get; set; }

    /// <summary>
    ///  类别
    /// </summary>
    public Guid? Type { get; set; }

    /// <summary>
    /// 联系人
    /// </summary>
    public string ContactName { get; set; }

    /// <summary>
    /// 联系人电话
    /// </summary>
    public string ContactPhone { get; set; }

    /// <summary>
    /// 状态（0：待审核；1：已审核）
    /// </summary>
    public int? Status { get; set; }

    /// <summary>
    ///  所属城市名字
    /// </summary>
    public string CityText { get; set; }

    /// <summary>
    /// 所属城市代码
    /// </summary>
    [JsonIgnore]
    public string CityCode { get; set; }


    /// <summary>
    ///  目的地id集合
    /// </summary>
    public List<string> CityCodeList => CityCode.StringToGeneric<List<string>>();

    /// <summary>
    /// 客户所在地址
    /// </summary>
    public string Address { get; set; }

    /// <summary>
    /// 所属销售人员（中文，以逗号隔开）
    /// </summary>
    [JsonIgnore]
    public string SalesPerson { get; set; }

    /// <summary>
    ///  所属销售人员集合（中文，以逗号隔开）
    /// </summary>
    public string SalesPersonList => string.Join("，", SalesPerson.StringToGeneric<List<string>>());


    /// <summary>
    ///  所属销售人员（编辑显示内容）
    /// </summary>
    public List<string> SalesPersonDetails =>
        !string.IsNullOrWhiteSpace(SalesPerson)
            ? JsonConvert.DeserializeObject<List<string>>(SalesPerson)
            : new List<string>();


    /// <summary>
    ///  备注
    /// </summary>
    public string Remark { get; set; }

    /// <summary>
    /// 账户余额
    /// </summary>
    public decimal? Price { get; set; }

    /// <summary>
    /// 授信额度
    /// </summary>
    public decimal? CreditPrice { get; set; }

    /// <summary>
    /// 初始授信额度
    /// </summary>
    public decimal? CreditPriceInitial { get; set; }

    /// <summary>
    /// 客户编号
    /// </summary>
    public int Code { get; set; }

    /// <summary>
    /// 登录名
    /// </summary>
    public string LoginName { get; set; }

    /// <summary>
    ///  商户密钥
    /// </summary>
    public string Key { get; set; }

    /// <summary>
    /// 冻结金额
    /// </summary>
    public decimal? FrozenAmount { get; set; }

    /// <summary>
    ///  排序字段：值越大越靠前
    /// </summary>
    public long Sort { get; set; }


}

/// <summary>
///  客户选项数据输出体
/// </summary>
public class CustomerOptionDataOutputDto
{
    /// <summary>
    /// 客户地址
    /// </summary>
    public string Address { get; set; }

    /// <summary>
    /// 联系人
    /// </summary>
    public string ContactName { get; set; }

    /// <summary>
    /// 联系人电话
    /// </summary>
    public string ContactPhone { get; set; }
}





